


#ifndef PF_LAYERLIST_H
#define PF_LAYERLIST_H

#include <QList>
#include "lx_Export.h"

class PF_Layer;
class PF_LayerListObserver;

/**
 * A list of layers.
 *

 */
class LX_EXPORT PF_LayerList {
public:
    PF_LayerList();
    virtual ~PF_LayerList() {}

    void clear();

    /**
     * @return Number of layers in the list.
     */
    unsigned int count() const {
        return layers.count();
    }

    /**
     * @return Layer at given position or NULL if i is out of range.
     */
    PF_Layer* at(unsigned int i) {
        return layers.at(i);
    }

    void activate(const QString& name, bool notify = false);
    void activate(PF_Layer* layer, bool notify = false);
    //! @return The active layer of NULL if no layer is activated.
    PF_Layer* getActive() {
        return activeLayer;
    }
    virtual void add(PF_Layer* layer);
    virtual void remove(PF_Layer* layer);
    virtual void edit(PF_Layer* layer, const PF_Layer& source);
    PF_Layer* find(const QString& name);
    int getIndex(const QString& name);
    int getIndex(PF_Layer* layer);
    void toggle(const QString& name);
    void toggle(PF_Layer* layer);
    void toggleLock(PF_Layer* layer);
    void freezeAll(bool freeze);
    //! @return First layer of the list.
    //PF_Layer* firstLayer() {
    //    return layers.first();
    //}
    /** @return Next layer from the list after
     * calling firstLayer() or nextLayer().
     */
    //PF_Layer* nextLayer() {
    //    return layers.next();
    //}

    void addListener(PF_LayerListObserver* listener);
    void removeListener(PF_LayerListObserver* listener);
	
	/**
	 * Sets the layer lists modified status to 'm'.
	 */
	void setModified(bool m) {
		modified = m;
	}
	
	/**
	 * @retval true The layer list has been modified.
	 * @retval false The layer list has not been modified.
	 */
    virtual bool isModified() const {
        return modified;
    }

    friend std::ostream& operator << (std::ostream& os, PF_LayerList& l);

private:
    //! layers in the graphic
    QList<PF_Layer*> layers;
    //! List of registered LayerListListeners
    QList<PF_LayerListObserver*> layerListListeners;
    //! Currently active layer
    PF_Layer* activeLayer;
    /** Flag set if the layer list was modified and not yet saved. */
    bool modified;
};

#endif
